package com.mxy.myapplication.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * ViewPager的碎片adapter
 */

public class AdapterForMainActivityViewPager extends FragmentPagerAdapter {

    private ArrayList<Fragment> pagelist;
    private ArrayList<String> namelist;


    public AdapterForMainActivityViewPager(FragmentManager fm,ArrayList<Fragment> pagelist,ArrayList<String> namelist) {
        super(fm);
        this.pagelist=pagelist;
        this.namelist=namelist;
    }


    @Override
    public CharSequence getPageTitle(int position) {
        return namelist.get(position);
    }

    @Override
    public Fragment getItem(int position) {
        return pagelist.get(position);
    }

    @Override
    public int getCount() {
        return pagelist.size();
    }
}